package com.woniu.user.controller;

import com.woniu.user.pojo.TUserWhite;
import com.woniu.user.service.TUserWhiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杜梅杰
 * @description 白名单API
 * @date 2024/5/8 18:50
 */
@RestController
@Api(tags = "白名单API")
public class WhiteController {
    @Autowired
    private TUserWhiteService whiteService;

    @GetMapping("/initWhite")
    @ApiOperation(value = "初始化白名单",tags = "初始化白名单")
    public String initWhite() {
        return whiteService.initWhite();
    }

    @PostMapping("/addWhite")
    @ApiOperation(value = "新增白名单",tags = "新增白名单")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "path",value = "路径",required = true),
            @ApiImplicitParam(name = "routeType",value = "路径类型",required = true),
    })
    public String addWhite(String path,String routeType) {
        return whiteService.addWhite(path,routeType);
    }

    @PostMapping("/updateWhite")
    @ApiOperation(value = "修改白名单",tags = "修改白名单")
    public String updateWhite(@RequestBody TUserWhite white) {
        return whiteService.updateWhite(white);
    }

}
